package com.gkj.algorithm;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.*;

@SpringBootTest(classes = {NiuKeAlgorithm.class})
public class NiuKeAlgorithm {
    @Test
    public ArrayList<Integer> printListFromTailToHead(ListNode listNode) {

        ArrayList<Integer> integers = new ArrayList<>();
        ListNode next = listNode;
        ListNode next2 = new ListNode(2);
        ListNode next3 = new ListNode(3);
        ListNode one = next;//使得每个节点都链接起来形成链表
        next.next = next2;
        next2.next = next3;
        while(true){
            integers.add(one.value);
            if(one == null){
                break;
            }
            one = one.next;
        }
        Collections.reverse(integers);
        return !(integers.isEmpty()) ? integers:new ArrayList<>();
    }

}
